package test.serverframe.armc.server.manager.enums;/**
 * Created by luoxuan on 2018/11/1.
 */

import org.springframework.http.HttpMethod;

/**
 * @Description
 * @Author LSY
 * @Date 2018/11/1 16:28
 * @ClassName test.serverframe.armc.server.manager.enums.HttpMethodEnum
 */
public enum HttpMethodEnum {
    /**
     * @Descripttion
     * @Author LSY
     * @Date 16:31
     * @Param
     * @Return
     **/
    GET{
        @Override
        public String key() {
            return "GET";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.GET;
        }
    },
    /*/**
     * @Descripttion
     * @Author LSY
     * @Date 16:31
     * @Param
     * @Return
     **/
    POST{
        @Override
        public String key() {
            return "POST";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.POST;
        }
    },

    HEAD{
        @Override
        public String key() {
            return "HEAD";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.HEAD;
        }
    },

    DELETE{
        @Override
        public String key() {
            return "DELETE";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.DELETE;
        }
    },

    OPTIONS{
        @Override
        public String key() {
            return "OPTIONS";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.OPTIONS;
        }
    },

    PATCH{
        @Override
        public String key() {
            return "PATCH";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.PATCH;
        }
    },

    PUT{
        @Override
        public String key() {
            return "PUT";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.PUT;
        }
    },

    TRACE{
        @Override
        public String key() {
            return "TRACE";
        }
        @Override
        public HttpMethod value() {
            return HttpMethod.TRACE;
        }
    };

    public abstract String key();

    public abstract HttpMethod value();

    public static HttpMethod getMethod(String method){
        HttpMethodEnum[] values= HttpMethodEnum.values();
        for (HttpMethodEnum value : values) {
            if (method.equalsIgnoreCase(value.key())){
                return value.value();
            }
        }
        return null;
    }
}
